package com.example.lzwphoto.common;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.math.BigInteger;

import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;

/**
 * @Desc: TODO
 * @Author: LvKun
 * @Date: 2024-02-07
 * @Version: 1.0
 */


public class JacksonObjectMapper extends ObjectMapper {

    public JacksonObjectMapper () {
        super();
//        未知属性不报异常
//        this.configure(FAIL_ON_UNKNOWN_PROPERTIES, false);

        this.getDeserializationConfig().withoutFeatures(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);

        SimpleModule simpleModule = new SimpleModule()
                .addSerializer(BigInteger.class, ToStringSerializer.instance)
                .addSerializer(Long.class, ToStringSerializer.instance);

        this.registerModule(simpleModule);
    }

}
